package com.lv.phuotbacnam.toolbox;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * Date and time utility methods
 */
public class DateTimeUtils {
    public static String normalDate(Calendar calendar) {
        return new SimpleDateFormat("d MMMM yyyy").format(calendar.getTime());
    }

    public static String amPmTime(Calendar calendar){
        return new SimpleDateFormat("hh.mma").format(calendar.getTime());
    }

    public static Date dateFrom(String dateInput){
        try {
            return new SimpleDateFormat("MM/dd/yyyy").parse(dateInput);
        } catch (ParseException e) {
            return null;
        }
    }
}